package com.tdk.bts.service;

import com.tdk.bts.dao.FilmScreenServiceDao;
import com.tdk.bts.dao.TheaterServiceDao;
import com.tdk.bts.entity.Theater;
import com.tdk.bts.util.Page;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class TheaterServiceImp implements TheaterService {
    private TheaterServiceDao theaterServiceDao = new TheaterServiceDao();
    @Override
    public Theater findTheaterByScreenId(int id) throws SQLException {
        return theaterServiceDao.findTheaterByScreenIds(id);
    }

    @Override
    public List<Theater> findAll() throws SQLException {
        List<Theater> list = theaterServiceDao.findAllTheater();
        return list;
    }

    @Override
    public Page<Theater> findByPageNo(int pageNo) throws SQLException {
        int count = theaterServiceDao.ThreatTotalCount();
        List<Theater> theaterList = theaterServiceDao.findTheaters(pageNo);
        Page<Theater> theaters = new Page<>(pageNo,5,theaterList,count);
        return theaters;
    }

    @Override
    public void deleteTheater(int id) throws SQLException {
        theaterServiceDao.deleteChosenTheater(id);
    }

    @Override
    public void addTheater(String name, int rows, int cols) throws SQLException {
        theaterServiceDao.insertTheater(name,rows,cols);
    }
}
